extends ../layout
block content
	div.row
		div.col-lg-9
			each blog in blogs
				div
					div.row
						div.panel.panel-default
							div.panel-heading
								h4
									a(href='/blogs/#{blog._id}') #{blog.title}
										if (blog.status == 1)
											span 【置顶】
							div.panel-body
								div(id='#{blog._id}').content.blog-body !{blog.content}
								div.text-right.blog-tag.margin-top
									span #{blog.createTime} | 浏览(#{blog.count}) | 评论(#{blog.comments.length})
			div.text-center
				- if(pageCount>1)
					ul.pagination
						-var suffix = search ? ('search='+search):'';
						li
							a(href='/blog?#{suffix}') &laquo;
						-for(var i=1; i<=pageCount; i++)
							if(index == i)
								li.active
									span #{i}
							else
								li
									a(href='/blog?index=#{i}&size=#{size}&#{suffix}') #{i}
						li
							a(href='/blog?index=#{pageCount}&size=#{size}&#{suffix}') &raquo;
		div.col-lg-3
			div.list-group#categories
				if(selectedCategory==='')
					a(href='/blog').list-group-item.active 全部
						span.badge.pull-right #{totalCount}
				else
					a(href='/blog').list-group-item 全部
						span.badge.pull-right #{totalCount}
				-var total=0;
				each category in categories
					-total+=category.blogCount;
					if(selectedCategory==category._id)
						a(href='/blog?category=#{category._id}').list-group-item.active #{category.name}
							span.badge.pull-right #{category.blogCount}
					else
						a(href='/blog?category=#{category._id}').list-group-item #{category.name}
							span.badge.pull-right #{category.blogCount}
				if(total<totalCount)
					if (selectedCategory==='others')
						a(href='/blog?category=others').list-group-item.active 其他
							span.badge.pull-right #{totalCount-total}
					else
						a(href='/blog?category=others').list-group-item 其他
							span.badge.pull-right #{totalCount-total}
			h5.gray 热门博客
			div.list-group.blog-title
				each blog in popular
					a(href='/blogs/#{blog._id}').list-group-item.single-line #{blog.title}

block scripts
	script(src='/ueditor/ueditor.parse.js')
	script.
		uParse('.content', {
			rootPath: '../'
		});